home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9104 / profiler.apr < prev    next >
Text File  |  1991-03-15  |  2KB  |  88 lines

  1.  
  2. * Listing 1
  3.  
  4. USE Timelog    && See structure in Figure 1
  5. ZAP
  6. APPEND FROM D:\Timelog.sdf TYPE SDF
  7. SET TALK OFF   && Optional
  8. lasttime = Seconds
  9. SKIP -1
  10. DO WHILE .NOT. BOF()
  11.   IF m->lasttime < Seconds
  12.                   && For the late night programmers
  13.       && (Seconds() returns seconds since midnight)
  14.     REPLACE Elapsed WITH m->lasttime+86400 - Seconds
  15.   ELSE
  16.     REPLACE Elapsed WITH m->lasttime - Seconds
  17.   ENDIF
  18.   lasttime = Seconds
  19.   SKIP -1
  20. ENDDO
  21. REPLACE Lines WITH 1 ALL
  22.  
  23.  
  24. * Listing 2
  25.  
  26. USE Prcsumry INDEX Prcsumry     && Indexed on
  27. Procname+Procfile
  28. ZAP
  29. handle = FOPEN('PRCSUMRY.DOC')
  30. FOR i = 1 TO 7
  31.     =FGETS(m->handle)   && Skip this text
  32. ENDFOR
  33. textstr = FGETS(m->handle)
  34. procfiles = VAL(LEFT(m->textstr,AT(' ',m->textstr)-1))
  35.  
  36. FOR i = 1 TO m->procfiles + 2
  37.     =FGETS(m->handle)   && Skip this text
  38. ENDDO
  39. FOR i = 1 TO m->procfiles
  40.     textstr = FGETS(m->handle)
  41.     procfile = LEFT(m->textstr,AT(' ',m->textstr)-1)
  42.     =FGETS(m->handle)   && Skip this text
  43.     DO WHILE .NOT. EMPTY(m->textstr)
  44.         textstr = ALLTRIM(FGETS(m->handle))
  45.         IF LEFT(m->textstr,10)='Contains: '
  46.             procname = STRTRAN(SUBSTR(m->textstr,11,;
  47.                        AT('
  48. ',m->textstr,2)-11),'()','')
  49.             APPEND BLANK
  50.             GATHER MEMVAR
  51.         ENDIF
  52.     ENDDO
  53.     =FGETS(m->handle)   && Skip this text
  54.     =FGETS(m->handle)   && Skip this text
  55. ENDFOR
  56. CLOSE ALL
  57.  
  58.  
  59. * Listing 3
  60.  
  61. SELECT 2
  62. USE Prcsumry INDEX Prcsumry
  63. SELECT 1
  64. USE Timelog
  65. SET RELATION TO Program INTO Prcsumry
  66. INDEX ON Prcsumry->Procfile+Lineno TO Temp ;
  67.  FOR .NOT. EMPTY(Prcsumry->Procfile)
  68. DO WHILE .NOT. EOF()
  69.   procfile = Prcsumry->Procfile
  70.   handle = FOPEN(m->Procfile)
  71.   filesize = FSEEK(m->handle,0,2)
  72.   =FSEEK(m->handle,0)     && beginning of file
  73.   bytesread = 0
  74.   lineno = 1
  75.   DO WHILE bytesread < m->filesize
  76.     code = FGETS(m->handle,1024)
  77.     IF SEEK(m->procfile+STR(m->lineno,5))
  78.       REPLACE Code WITH m->code
  79.     ENDIF
  80.     bytesread = m->bytesread + LEN(m->code)+2
  81.     lineno = m->lineno + 1
  82.   ENDDO
  83.   SEEK Prcsumry->Procfile
  84.   LOCATE FOR Prcsumry->Procfile <> m->procfile REST
  85. ENDDO
  86.  
  87.  
  88.